package com.qww.factory.simplefactory;

public class OrderPizza {

    private Pizza pizza;
    private SimpleFactory factory;

    public OrderPizza(SimpleFactory factory) {
        setFactory(factory);
    }

    public void setFactory(SimpleFactory factory) {
        this.factory = factory;
    }

    public void order(OrderType orderType) {
        pizza = factory.createPizza(OrderType.CHEESE_PIZZA);
        if (pizza == null) {
            System.out.println("order unsuccessfully! ");
            return;
        }
        System.out.println("order successfully! ");
        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();
    }

    public OrderPizza(OrderType orderType) {
        order(orderType);
    }

}
